package com.sports.controller;

import com.sports.pojo.Sports;
import com.sports.service.ISportsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sports")
public class SportsController {
    @Autowired
    private ISportsService service;
    @GetMapping
    public List<Sports> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public Sports getInfo(@PathVariable Integer id) {
            return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody Sports sports){
        int rlt= service.add(sports);
        return rlt;
    }
    @PutMapping
    public Integer update(@RequestBody Sports sports){
        return service.update(sports);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
